﻿namespace LendLess.IPQuery
{
    using System;
    using System.Web;
    using System.Windows.Forms;

    public class IPQuery
    {
        public static IPLocation FormApp(string ip)
        {

            return IPQuery.DataPath(Application.StartupPath + "/Bin/Ip.dat", ip);
        }

        public static IPLocation Query(string ip)
        {
            string dataPath = "";
            try
            {
                dataPath = HttpContext.Current.Server.MapPath("/Bin/") + "Ip.dat";
            }
            catch (Exception)
            {
                dataPath = Application.StartupPath + "/Bin/Ip.dat";
            }
             return IPQuery.DataPath(dataPath,ip);
        }

        public static IPLocation WebApp(string ip)
        {
            string dataPath = HttpContext.Current.Server.MapPath("/Bin/") + "Ip.dat";
            return IPQuery.DataPath(dataPath,ip);
        }

        public static IPLocation DataPath(string dataPath,string ip)
        {
            IPLocator locator = new IPLocator(dataPath);
            return locator.Query(ip);
        }
    }
}

